﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using Animation;
using MapLibrary.Players;
using MapLibrary.Players.Skills;
using AI;
using MapLibrary.Players.CollisionResponse;

namespace Enemies
{
    class Malaria : Enemy, IDamageable
    {
        

        public NetSprite Net { get; set; }

        public Malaria() : base()
        {
            Net = null;
            maxHealth = 100;
            health = maxHealth;

            Hookable = false;
        }

        public override void DealDamage(int dmg)
        {
            health -= dmg;

            if (health <= 0)
            {
                if (Net != null)
                {
                    Net.RemoveSprite(this);
                }
                Die();
                World.CurrentLevel.AddBodyToRemove(this);
            }
        }

        public override bool MyOnCollision(Fixture f1, Fixture f2, Contact contact)
        {
            if (Net != null)
            {
                return false;
            }
            
            Sprite s1 = f1.Body.UserData as Sprite;
            Sprite s2 = f2.Body.UserData as Sprite;

            if (s2 == null)
            {
                return true;
            }

            Player p = s2 as Player;

            if (p != null)
            {
                MalariaBot bot = Bot as MalariaBot;
                if (bot.TimeToAttack == 0)
                {
                    p.DealDamage(1);

                    bot.ResetAttackTime();
                }

                return false;
            }

            if (s2 as Malaria != null || s2 as NetSprite != null)
            {
                return false;
            }

            return false;
        }
    }
}
